package test.study.concurrent.jmh.sample1;

import lombok.SneakyThrows;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;

@Warmup(iterations = 3)
@Measurement(iterations = 6)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@BenchmarkMode(value = Mode.AverageTime)
public class SetDemo {

    List<String> names = new ArrayList<>();
    Set<String> namesSet = new HashSet<>();
    List<String> finds = new ArrayList<>();

    @Param({"100", "1000", "10000"})
    int originLen;

//    @Setup
//    public void setUp() {
//        Faker faker = new Faker(Locale.CHINA);
//        names = faker.collection(() -> faker.name().name()).len(originLen).generate();
//        namesSet = new HashSet<>(names);
//        finds =  faker.collection(() -> faker.name().name()).len(100).generate();
//    }

    @SneakyThrows
    public static void main(String[] args) {

        Options opt = new OptionsBuilder()
                .include(SetDemo.class.getSimpleName())
                .forks(1)
                .build();

        new Runner(opt).run();
    }
}
